/*
ID: icerupt1
PROG: ttwo
LANG: C++11
*/

/* solution
 *
 * for the max_tick, for farmer john, (pos, direction)'s combination is 400,
 * the same goes for cow, this multiplies out to 400 * 400 = 160 000 different
 * configurations for farmer john and cow. so the max_tick is 160 000.
 *
*/
#include <fstream>
#include <iostream>

std::ifstream fin {"ttwo.in" };
std::ofstream fout{"ttwo.out"};

struct pos { int x; int y; };

struct direction
{
	int x = -1;
	int y =  0;

	void clockwise()
	{
		std::swap(x, y);
		y = -y;
	}
};

int const max_tick = 400 * 400;
int const n = 10;
bool map[n+1][n+1];
pos f, c;
direction fd, cd;

pos operator+(pos a, direction ad)
{
	a.x += ad.x;  a.y += ad.y;
	return a;
}

bool operator==(pos a, pos b)
{
	return a.x == b.x && a.y == b.y;
}

bool inrange(pos a)
{
	return ((0 <= a.x && a.x < n) && (0 <= a.y && a.y < n));
}

bool move(pos &a, direction ad)
{
	pos tmp = a + ad;
	if (inrange(tmp) && map[tmp.x][tmp.y]) {
		a = tmp;  return true;
	}
	return false;
}

int main()
{
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			char ch;
			fin >> ch;
			if (ch != '*') map[i][j] = true;
			if (ch == 'C') { c.x = i;  c.y = j; }
			else
			if (ch == 'F') { f.x = i;  f.y = j; }
		}
	for (int tick = 0; tick < max_tick; tick++) {
		if (f == c) {
			std::cout << tick << '\n';
			fout << tick << '\n';
			return 0;
		}
		if (!move(f, fd)) fd.clockwise();
		if (!move(c, cd)) cd.clockwise();
	}
	std::cout << "0\n";
	fout << "0\n";
}
